package com.springmvc.study.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

@Controller
public class RestFulController {

    // 原来的风格：   http://localhost:8080/add?a=1&b=4
    // RestFul风格： http://localhost:8080/add/a/b

    /**
     *
     * @param a
     * @param b
     * @param model
     * @return
     */
   /* public String test(int a, int b, Model model) {
        int res = a + b;// http://localhost:8080/add?a=1&b=4
        model.addAttribute("msg", "结果为" + res);
        return "test";
    }*/// value path互为别名  name
    @RequestMapping(value = "/add/{a}/{b}", method = RequestMethod.GET)
//    @GetMapping
//    @PostMapping("/add/{}/{}")
    public String test(@PathVariable int a, @PathVariable String b, Model model) {
        String res = a + b;
        model.addAttribute("msg", "结果为" + res);
        return "test";
    }
}
